package com.example.localareanetworkchat.fragment.profile

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.navigation.Navigation
import com.example.localareanetworkchat.R
import com.example.localareanetworkchat.persistence.entity.User
import kotlinx.android.synthetic.main.fragment_profile.*


class ChatGroupUserProfileFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_chat_group_user_profile, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)

        val user = arguments?.getParcelable<User>("user")
        requireActivity().findViewById<Toolbar>(R.id.toolbar).title = user?.name
        requireActivity().findViewById<Toolbar>(R.id.toolbar).setNavigationIcon(R.drawable.ic_baseline_keyboard_backspace_24)
        val navController = Navigation.findNavController(requireView())
        requireActivity().findViewById<Toolbar>(R.id.toolbar).setNavigationOnClickListener {
            navController.navigate(R.id.messageFragment)
        }

        tv_chat_user_profile_name_first.text = user?.name?.first()?.uppercase()
        tv_chat_user_profile_name.text = user?.name
        tv_chat_user_profile_uid.text = user?.uid
    }

}